<% layout('/layouts/default.html', {title: '考核任务指标表管理', libs: ['dataGrid','fileupload','validate']}){ %>
<div class="main-content">
	<div class="box box-main" id="topId">
		<div class="box-header">
			<div style="float: left">
				<div class="form-group">
					<button type="button" class="btn btn-sm btn-default" id="btnCancel" onclick="js.closeCurrentTabPage()"><i class="fa fa-reply-all"></i> ${text('返回')}</button>
				</div>
			</div>
			<#form:form id="searchForm" model="${dcSupExamQuotaInfo!}" action="${ctx}/quota/dcSupExamQuotaInfo/listData?quotaId=${dcSupExamQuota.id}&quotaGroup=2" method="post" class="form-inline "
			data-page-no="${parameter.pageNo}" data-page-size="${parameter.pageSize!5}" data-order-by="${parameter.orderBy}">
			<div style="float: right">
				<div class="form-group">
					<label class="control-label">${text('类别')}：</label>
					<div class="control-inline width-160">
						<#form:select path="quotaType" dictType="dc_quotaType_dan" blankOption="true" data-placeholder="请选择" itemLabel="dictLabel" itemValue="dictValue" class="form-control width-160"/>
					</div>
				</div>
				<div class="form-group">
					<button type="submit" class="btn btn-primary btn-sm">${text('查询')}</button>
					<button onclick="cz();" class="btn btn-default btn-sm">${text('重置')}</button>
				</div>
			</div>
		</#form:form>

	</div>
	<div class="box-body" >

		<div style="float: left;">
			<div class="form-group">
				${text('单项考核指标')}
			</div>
		</div>
		<style>
			.ou{
				width: 150px;
				height: 40px;
				background-color: #f2f2f2;
				text-align: center;
				display: flex;
				align-items: center;
				justify-content: space-around;
				color:#70b1a7 ;
				border-radius: 10px 0px 10px 0px ;
				border-bottom: 2px solid #1abc9c;
			}

			.box-body{
				border-bottom: 1px solid #e7e7e7;
				margin: 10px 10px;
			}
			.box-header{
				border-radius: 0px 0px 0px 0px ;
				border-bottom: 10px solid #eee !important;
			}

			.form-horizontal{
				margin-bottom: 10px;
			}
		</style>
	</div>

	<div class="box-body">
		<table id="dataGrid"></table>
		<div id="dataGridPage"></div>
	</div>

	<div class=" box-body">
				<div class="ui-layout-content">
					<#form:form id="searchForm2" model="${DcSupExamSumQuotaOrg!}" action="${ctx}/quota/dcSupExamQuotaInfo/listDanOrgData" method="post" class="form-inline hide"
					data-page-no="${parameter.pageNo}" data-page-size="${parameter.pageSize!20}"
					data-order-by="${parameter.orderBy}">
					<div class="form-group">
						<label class="control-label">${text('指标')}：</label>
						<div class="control-inline width-90">
							<#form:input name="quotaInfoId" id="quotaInfoId" class="form-control"/>
						</div>
					</div>
				</#form:form>
				<table id="dataGrid2"></table>
				<div id="dataGrid2Page"></div>
			</div>

</div>
	<#form:form id="inputForm" model="${dcSupExamQuota}" action="${ctx}/quota/dcSupExamQuota/save" method="post" class="form-horizontal">
	<p style="height: 10px"></p>
	<div class="row">
	<div class="col-xs-6">
		<div class="form-group">
			<label class="control-label col-sm-4" title="">
				<span class="required hide">*</span> ${text('联系人&nbsp;&nbsp;')}：<i class="fa icon-question hide"></i></label>
			<div class="col-sm-8">
				<#form:hidden path="id" />
				<#form:input path="contactName" class="form-control" readonly="true"/>
			</div>
		</div>
	</div>
	
		<div class="col-xs-6">
			<div class="form-group">
				<label class="control-label col-sm-4" title="">
					<span class="required hide">*</span> ${text('联系电话')}：<i class="fa icon-question hide"></i></label>
				<div class="col-sm-8">
					<#form:input path="contactPhone" class="form-control" readonly="true"/>
					<#form:hidden path="dcSupExamQuotaInfoList" class="form-control"/>
					<#form:hidden path="createOrg" />
				</div>
			</div>
		</div>
	</div>
		<p class="h"></p>
	<div class="row">
		<div class="col-xs-12">
			<div class="form-group">
				<span class="control-label col-sm-2">
					<span class="required hide">*</span>附件上传：</span>
				<div class="col-sm-10">
					<#form:fileupload id="uploadFile" bizKey="${dcSupExamQuota.id}" bizType="dcSupExamQuota_file"
					uploadType="all" class="" readonly="true" preview="true" maxUploadNum="5" cueWords="若今年单项指标比去年少，请在附件中说明,最多可选 5 个"/>
				</div>
			</div>
		</div>
	</div>
<p class="border-p"></p>
</div>

</div>
</#form:form>
<% } %>
<style>
</style>
<script src="${ctxStatic}/m/js/total.js?${_version}"></script>
<script>
	$(function (){
		window.location.hash="#topId";
	})
// 初始化DataGrid对象
$('#dataGrid').dataGrid({
	searchForm: $("#searchForm"),
	columnModel: [
		{header:'${text("指标类别")}', name:'quotaType', width:250,align:"center",
			formatter: function(val, obj, row, act){
				return js.getDictLabel(${@DictUtils.getDictListJson('dc_quotaType')},
						val, '${text("未知")}', true);
			},
			unformat: function(val, obj, cell){
				return $('#'+obj.rowId+'_quotaType').val();
			},
			editable:true, edittype:'select', editoptions:{'class':'form-control',
				items: $.merge([{dictLabel:'&nbsp;',dictValue:''}],
						${@DictUtils.getDictListJson('dc_quotaType')}),
				itemLabel: 'dictLabel', itemValue: 'dictValue', dataInit: function(element){
					$(element).select2().on("change",function(){$(this).resetValid()});
				}
			}
		},
		{header:'${text("序号")}', name:'sortNum', width:100, align:"center"},
		{header:'${text("主键")}', name:'id', hidden:true},
		{header:'${text("指标名称")}', name:'quotaContent', index:'a.quota_content', width:350, align:"left"},
	],
	showRownum: false,
	autoGridHeight: function(){
		return 200;
	},
	onSelectRow: function(id, isSelect, event){
		$('#quotaInfoId').val(id);
		$('#dataGrid2').dataGrid('refresh');
	},
	ajaxSuccess: function(data){
		$('#dataGrid').dataGrid('setSelectRow', $('#dataGrid').dataGrid('getSelectRows')[0], true);
	}
});

$('#dataGrid2').dataGrid({
	searchForm: $("#searchForm2"),
	dataGridPage: $('#dataGrid2Page'),
	autoGridHeight: function(){
		return 800;
	},
	columnModel: [
		{header:'${text("排序")}', name:'rowno',  width:100, align:"center"},
		{header:'${text("排序")}', name:'quotaInfoId',  hidden:true},
		{header:'${text("排序")}', name:'id',  hidden:true},
		{header:'${text("被考核单位名称")}', name:'exameOrgName',  width:150, align:"left"},
		{header:'${text("单位")}', name:'quotaUnit', index:'a.quota_unit', width:100, align:"center",
			editable:true, edittype:'text', editoptions:{'maxlength':'200', 'class':'form-control',
				'placeholder':'例:亿元、万元、个、条、家、项、户等;若无则不填'},
			unformat: function(val, obj, cell){
				return $('#'+obj.rowId+'_quotaUnit').val();
			}

		},
		{header:'${text("权数")}', name:'quotaWeight', index:'a.quota_weight', width:60, align:"center",
			editable:true, edittype:'text', editoptions:{'maxlength':'200', 'class':'form-control'},
			unformat: function(val, obj, cell){
				return $('#'+obj.rowId+'_quotaWeight').val();
			},
			formatter: function(val, obj, row, act){
				if (val==''||typeof val=="undefined"){val=0;}
				return val.toFixed(2);
			}
		},
		{header:'${text("本年度目标")}', name:'currentYaerGoal', index:'a.current_yaer_goal', width:150, align:"center",
			editable:true, edittype:'text', editoptions:{'maxlength':'200', 'class':'form-control'},
			unformat: function(val, obj, cell){
				return $('#'+obj.rowId+'_currentYaerGoal').val();
			}
		},
		{header:'${text("考核方式")}', name:'assessMethod',  width:100, align:"center",
			formatter: function(val, obj, row, act){
				return js.getDictLabel(${@DictUtils.getDictListJson('dc_exam_assessment')},
						val, '${text("未知")}', true);
			},
			unformat: function(val, obj, cell){
				return $('#'+obj.rowId+'_assessMethod').val();
			},
			editable:true, edittype:'select', editoptions:{'class':'form-control',
				items: $.merge([{dictLabel:'&nbsp;',dictValue:''}],
						${@DictUtils.getDictListJson('dc_exam_assessment')}),
				itemLabel: 'dictLabel', itemValue: 'dictValue', dataInit: function(element){
					$(element).select2().on("change",function(){$(this).resetValid()});
				}
			}
		},
		{header:'${text("备注")}', name:'remarks',  width:100, align:"center",
			formatter: function(val, obj, row, act){
				return js.getDictLabel(${@DictUtils.getDictListJson('dc_exam_remarks')},
						val, '${text("未知")}', true);
			},
			unformat: function(val, obj, cell){
				return $('#'+obj.rowId+'_remarks').val();
			},
			editable:true, edittype:'select', editoptions:{'class':'form-control',
				items: $.merge([],
						${@DictUtils.getDictListJson('dc_exam_remarks')}),
				itemLabel: 'dictLabel', itemValue: 'dictValue', dataInit: function(element){
					$(element).select2().on("change",function(){$(this).resetValid()});
				}
			}
		},
	],
	showRownum: false,
	// 加载成功后执行事件
	editGridInitRowNum: 0,
	emptyDataHint: true,
	ajaxSuccess: function(data){

	}
});
	function updateInfo(id) {

		let allData =JSON.stringify($('#dataGrid2').dataGrid('getRowData',$('#dataGrid2').dataGrid('getSelectRow')));
		let dcSupExamQuotaOrg ={"dcSupExamQuotaOrg":allData}
		js.ajaxSubmit({url:"${ctx}/quota/dcSupExamQuotaInfo/saveStrOrg",data:dcSupExamQuotaOrg,dataType: 'json',callback:function (data){
				if (data.result=="true"){
					js.showMessage(data.message);
				}else {
					js.showMessage(data.message);
				}
			}})
	}
//打开新的标签
function addQuotaInfo(QuotaId) {
	js.addTabPage(null, "新增指标","${ctx}/quota/dcSupExamQuotaInfo/form?quotaId="+QuotaId+"&quotaGroup=${dcSupExamQuota.quotaGroup}", true);
}
$("#btnSubmit").click(function(){
//示范一个公告层
	layer.open({
		type: 1
		,title: ['单项指标报送', 'font-size:18px; color:orange;'] //不显示标题栏
		,btn: ['确认', '取消']
		,btnAlign: 'c'
		,area: '300px;'
		,moveType: 1 //拖拽模式，0或者1
		,content: '<div style="padding: 50px">您确定报送本次单项指标吗</div>'
		,yes: function(layero){


					js.ajaxSubmitForm($('#inputForm'), function(data){
						js.showMessage(data.message);
						if(data.result == Global.TRUE){
							js.closeCurrentTabPage(function(contentWindow){
								contentWindow.page();
							});
						}
					}, "json");


		}
	});

})
function cz(){
	searchForm.reset();
	$('#dataGrid').dataGrid('reloadGrid');
}

function addKpi4(QuotaId) {
	window.location.href ='${ctx}/quota/dcSupExamQuotaInfo/exportDan?quotaId='+QuotaId;
}
</script>